#include "SceneNodeUtils.h"

using namespace Ogre;

namespace utils
{
	void SceneNodeUtils::RecursiveSetBoundingBox(SceneNode* node, bool show)
	{
		SceneNode::ChildNodeIterator itr = node->getChildIterator();
		while (itr.hasMoreElements())
			{
				SceneNode* child = static_cast<SceneNode*>(itr.getNext());
				SceneNodeUtils::RecursiveSetBoundingBox(child, show);
			}
		node->showBoundingBox(show);
	}

	SceneNode* SceneNodeUtils::createOrRetrieve(SceneManager* smgr, String name)
	{
		SceneNode* node;
		try
			{
				node = smgr->getSceneNode(name);
			}
		catch(Ogre::Exception& e)
			{
				node = smgr->getRootSceneNode()->createChildSceneNode(name);
			}
		return node;
	}
}
